import request from '@/utils/request'

// 获取物流商
export const getProviderList = (params: any) => {
  return request
    .get('/logistics/providers', {
      params,
    })
    .then((res: any) => {
      return res
    })
}

// 创建物流商
export const createProvider = (params: any) => {
  return request.post('/logistics/providers/', params).then((res: any) => {
    return res
  })
}

// 更新物流商
export const updateProvider = (id: number, params: any) => {
  return request.put(`/logistics/providers/${id}`, params).then((res: any) => {
    return res
  })
}

// 删除物流商
export const deleteProviderById = (id: number) => {
  return request.delete(`/logistics/providers/${id}`).then((res: any) => {
    return res
  })
}

/**
 * 物流订单
 */
// 获取物流订单
export const getLogisticsOrderList = (params: any) => {
  return request
    .get('/logistics/orders', {
      params,
    })
    .then((res: any) => {
      return res
    })
}
// 根据ID获取物流订单
export const getLogisticsOrderById = (id: number) => {
  return request.get(`/logistics/orders/${id}`).then((res: any) => {
    return res
  })
}
// 生成物流订单
export const createLogisticsOrder = (params: any) => {
  console.log(params)
  return request.post(`/logistics/orders/${params.OrderID}`, params).then((res: any) => {
    return res
  })
}
// 更新物流订单
export const updateLogisticsOrder = (id: number, params: any) => {
  return request.put(`/logistics/orders/${id}`, params).then((res: any) => {
    return res
  })
}
// 删除物流订单
export const deleteLogisticsOrderById = (id: number) => {
  return request.delete(`/logistics/orders/${id}`).then((res: any) => {
    return res
  })
}
// 删除物流订单
export const deleteLogisticsOrderByIdList = (data: any) => {
  return request.delete(`/logistics/orders/dl`, { data }).then((res: any) => {
    return res
  })
}
